package com.csun.cmny.provider.service.impl;

import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.DmcPhoneEventMapper;
import com.csun.cmny.provider.model.domain.DmcPhoneEvent;
import com.csun.cmny.provider.model.dto.phone.PhoneEventPageQuery;
import com.csun.cmny.provider.service.DmcPhoneEventService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-01-09 09:34
 * @Description: the dmc phone event service impl.
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class DmcPhoneEventServiceImpl extends BaseService<DmcPhoneEvent> implements DmcPhoneEventService {

    @Resource
    private DmcPhoneEventMapper dmcPhoneEventMapper;

    /**
     * query phone event list with page
     *
     * @param phoneEventPageQuery the phone event query page
     *
     * @return the list.
     */
    @Override
    public PageInfo queryEventListWithPage(PhoneEventPageQuery phoneEventPageQuery) {

        PageHelper.startPage(phoneEventPageQuery.getPageNum(), phoneEventPageQuery.getPageSize());

        List<DmcPhoneEvent> phoneEventList = dmcPhoneEventMapper.queryEventListWithPage(phoneEventPageQuery);

        return new PageInfo<>(phoneEventList);
    }

    /**
     * delete phone event by device id
     *
     * @param deviceId device id
     * @return the int.
     */
    @Override
    public Integer deletePhoneEventByDeviceId(Long deviceId) {

        return dmcPhoneEventMapper.deletePhoneEventByDeviceId(deviceId);
    }
}
